package com.cloudcc.mobile.dao.impl;

import android.content.Context;

import com.cloudcc.cloudframe.net.async.EventRequest;
import com.cloudcc.cloudframe.net.async.TianYanChaRequest;
import com.cloudcc.mobile.dao.BaseEngine;
import com.cloudcc.mobile.dao.CallLogDao;
import com.cloudcc.mobile.entity.CallLogMatchEntity;
import com.cloudcc.mobile.entity.JurisdictionEntity;
import com.cloudcc.mobile.entity.MoreJurisdictionEntity;
import com.cloudcc.mobile.entity.map.NearByMapInfo;
import com.cloudcc.mobile.event.BeauEventList;
import com.loopj.android.http.RequestParams;

import org.apache.http.Header;

import java.util.List;

/**
 * Created by lin on 2017/6/7.
 *
 * 通话记录匹配
 */

public class CallLogDaoImpl extends BaseEngine implements CallLogDao {

    @Override
    public void CallLogMatch(String objectApiName, String expressions, String fields, BeauEventList.CallLogMatchEvent Event) {
        EventRequest<List<CallLogMatchEntity>> eventRequest = new EventRequest<List<CallLogMatchEntity>>() { };
        eventRequest.setEvent(Event);
        RequestParams params = new RequestParams();
        params.put("objectApiName", objectApiName);
        params.put("expressions", expressions);
        params.put("fields", fields);
        params.put("isAddDelete", false);
        sendPost(params, "cquery", eventRequest);
    }


    @Override
    public void getJurisdiction(String prefix, BeauEventList.JurisdictionEvent Event) {
        EventRequest<JurisdictionEntity> eventRequest = new EventRequest<JurisdictionEntity>() { };
        eventRequest.setEvent(Event);
        RequestParams params = new RequestParams();
        params.put("prefix", prefix);
        sendPost(params, "getObjectPermissionByPrefix", eventRequest);
    }

    @Override
    public void getMoreJurisdiction(String prefix, BeauEventList.MoreJurisdictionEvent Event) {
        EventRequest<List<MoreJurisdictionEntity>> eventRequest = new EventRequest<List<MoreJurisdictionEntity>>() { };
        eventRequest.setEvent(Event);
        RequestParams params = new RequestParams();
        params.put("prefixs", prefix);
        sendPost(params, "getObjectPermissionByPrefixs", eventRequest);
    }

    @Override
    public void getTianYanCha(Context context , String url , Header[] headers, RequestParams params, BeauEventList.NearByTianYanChaEvent Event){
        TianYanChaRequest eventRequest = new TianYanChaRequest();
        eventRequest.setEvent(Event);
        sendGetHeader(context , url,headers,params,eventRequest);
    }

    @Override
    public void getNearbyObjects(String prefix, String latitude, String langitude, String distance, BeauEventList.NearByObjectEvent event) {
        EventRequest<NearByMapInfo> eventRequest = new EventRequest<NearByMapInfo>() { };
        eventRequest.setEvent(event);
        RequestParams params = new RequestParams();
        params.put("prefix", prefix);
        params.put("latitude", latitude);
        params.put("langitude", langitude);
        params.put("distance", distance);
        sendPost(params, "getNearbyObject", eventRequest);
    }
}
